package card;

import java.util.Calendar;
import java.util.GregorianCalendar;

public class CardInfo {
	private long cardID;
	private String cardNumber;
	private CardType cardType;
	private CardTerm cardTerm;
	private StartCardRideQuantity cardRideQuantity;
	private State state;
	private int rideQuantity;
	private Calendar startWorkingDate;
	private Calendar endWorkingDate;

	public CardInfo(long cardID, String cardNumber, CardType cardType,
			CardTerm cardTerm, StartCardRideQuantity cardRideQuantity,
			State state, Calendar startWorkingDate) {
		this.cardID = cardID;
		this.cardNumber = cardNumber;
		this.cardType = cardType;
		this.cardTerm = cardTerm;
		this.cardRideQuantity = cardRideQuantity;
		this.state = state;
		this.rideQuantity = cardRideQuantity.getRideQuantity();
		this.startWorkingDate = startWorkingDate;
		if (cardTerm == CardTerm.MONTH_CARD) {
			endWorkingDate = new GregorianCalendar(
					startWorkingDate.get(Calendar.YEAR),
					startWorkingDate.get(Calendar.MONTH) + 1,
					startWorkingDate.get(Calendar.DAY_OF_MONTH));
		} else if (cardTerm == CardTerm.TEN_DAYS_CARD) {
			endWorkingDate = new GregorianCalendar(
					startWorkingDate.get(Calendar.YEAR),
					startWorkingDate.get(Calendar.MONTH),
					startWorkingDate.get(Calendar.DAY_OF_MONTH) + 10);
		} else if (cardTerm == CardTerm.UNLIMITED_PERIOD_CARD) {
			endWorkingDate = new GregorianCalendar(5000, 1, 1);
		}
	}

	public long getCardID() {
		return cardID;
	}

	public String getCardNumber() {
		return cardNumber;
	}

	public CardType getCardType() {
		return cardType;
	}

	public CardTerm getCardTerm() {
		return cardTerm;
	}

	public StartCardRideQuantity getCardRideQuantity() {
		return cardRideQuantity;
	}

	public State getState() {
		return state;
	}

	public int getRideQuantity() {
		return rideQuantity;
	}

	public void increaseRideQuantity(int count) {
		rideQuantity += count;
	}

	public void decreaseRideQuantity() {
		rideQuantity--;
	}

	public Calendar getStartWorkingDate() {
		return startWorkingDate;
	}

	public void setCardState(State state) {
		this.state = state;
	}

	public Calendar getEndWorkingDate() {
		return endWorkingDate;
	}
}
